<template>
	<view class="contain">
		<uni-forms ref="form" style="margin-top: 20px;">
			<uni-forms-item label="充值金额" name="">
				<uni-easyinput  v-model="money" placeholder="请输入你要充值的金额" />
			</uni-forms-item>
		</uni-forms>
		
		<view class="payment">
			<view @click="tiao(index)" v-for="(item,index) in payment" :key="index">
				<image style="width: 150rpx;" :src="item.src" mode="widthFix"></image>
				<view class="">{{item.text}}</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				money:'',
				number:'',
				payment:[
					{src:'../../static/card/weixin.png',text:'微信支付'},
					{src:'../../static/card/yinlian.png',text:'银联'},
					{src:'../../static/card/zhifubao.png',text:'支付宝支付'}
				]
			}
		},
		onLoad() {
			
		},
		methods: {
			async tiao(index){
				const res =await this.$request.addusermoney({rechargeMode:index+1,rechargeAmount:this.money})
				if(res.data.code==200){
					uni.showToast({
						icon:"success",
						title:"充值成功",
						success:()=> {
							setTimeout(()=>{
								uni.navigateTo({
									url:"/pages/payment/paymentinfo/paymentinfo?num="+res.data.orderNumber
								})
							},2000)
						}
					})
				}else{
					uni.showToast({
						icon:"error",
						title:"充值失败"
					})
				}
				
				// uni.navigateTo({
				// 	url:'/pages/payment/paymentinfo/paymentinfo'
				// })
				
			}
			
		}
	}
</script>

<style>
	.payment{
		display: grid;
		text-align: center;
		grid-template-columns: 1fr 1fr 1fr;
	}

</style>
